
#ifndef _UART_COMM_HDL_H
#define _UART_COMM_HDL_H

#include "comm_struct.h"
#include "ringbuff.h"


#define  STORE_NUM_TIME_SET        0
#define  STORE_NUM_SPEED_SET       1
#define  STORE_NUM_LED_SET         2
#define  STORE_NUM_CHARGE_SET      3
#define  STORE_NUM_CLEAN_SET       4
#define  STORE_NUM_MOTOR_SET       5
#define  STORE_NUM_LIGHTMODE_SET   6

#define  STROE_NUM_BRUSH_SET       7

#define  STORE_NUM_SHIELD_CLIFF    8
#define  STORE_NUM_SHIELD_CLIFF_A  9

#define  SET_SYNCHRO_TIME_SF       0.001

#define  SYNCRO_TIME_ERRO_MAX 3000

#define  HEARTBEAT_HOLD_TIME  (100 * 5)
#define  SPEEDCMD_HOLD_TIME   (100 * 5)
#define  SPEEDCMD_RETURN_CODE 0xAA

#define  BAT_STATUS_UNCHARGE     0x01
#define  BAT_STATUS_CHARGE       0x04
#define  BAT_STATUS_CHARGE_FULL  0x08

#define  BAT_STATUS_UNDERVOLTAGE 0x02


#define  CLEAN_MOTOR_STOP        0x00
#define  CLEAN_MOTOR_RUN_FAST    0x01
#define  CLEAN_MOTOR_RUN_MID     0x02
#define  CLEAN_MOTOR_RUN_SLOW    0x04


extern STR_UPLOAD_SPEED      commSpd;
extern STR_UPLOAD_ENCODER    commEncoder;
extern STR_UPLOAD_IMU        commImuRaw;
extern STR_UPLOAD_LIGHTFLOW  commLightflow;
extern STR_UPLOAD_WALL       commWall;
extern STR_UPLOAD_CHARGE     commCharge;
extern STR_UPLOAD_CLIFF      commCliff;
extern STR_UPLOAD_BUMPER     commBumper;
extern STR_UPLOAD_KEY        commKey;
extern STR_UPLOAD_DROP       commDrop;
extern STR_UPLOAD_CURRENT    commCurrent;
extern STR_UPLOAD_EVENT      commEvent;
extern STR_UPLOAD_BMS_MANAGE commBmsManage;


extern STR_COMM_FRAME  uploadframeSpd;
extern STR_COMM_FRAME  uploadframeEncoder;
extern STR_COMM_FRAME  uploadframeImuRaw;
extern STR_COMM_FRAME  uploadframeLightflow;
extern STR_COMM_FRAME  uploadframeWall;
extern STR_COMM_FRAME  uploadframeCharge;
extern STR_COMM_FRAME  uploadframeCliff;
extern STR_COMM_FRAME  uploadframeBumper;
extern STR_COMM_FRAME  uploadframeKey;
extern STR_COMM_FRAME  uploadframeDrop;
extern STR_COMM_FRAME  uploadframeCurrent;
extern STR_COMM_FRAME  uploadframeEvent;
extern STR_COMM_FRAME  uploadframeBmsManage;


extern STR_COMM_SPEED_SET  dataSpdSet;
extern STR_COMM_TIME_SET   dataTimeSet;
extern STR_COMM_LED_SET    dataLedSet;
extern STR_COMM_CHARGE_SET dataChargeSet;
extern STR_COMM_CLEAN_SET  dataCleanSet;
extern STR_COMM_MOTOR_SET  dataMotorSet;


extern STR_COMM_SPEED_SET  dataSpdSet;
extern STR_COMM_TIME_SET   dataTimeSet;
extern STR_COMM_LED_SET    dataLedSet;
extern STR_COMM_CHARGE_SET dataChargeSet;
extern STR_COMM_CLEAN_SET  dataCleanSet;
extern STR_COMM_MOTOR_SET  dataMotorSet;
extern STR_COMM_BRUSH_SET  dataBrushSet;



extern STR_COMM_FRAME      *cmdframGroup[];
extern volatile uint8_t interrupt_analysis_flg;
extern volatile uint8_t set_systemtime_flg;
extern volatile uint8_t frame_analysis_protect;

extern  void comm_struct_init(void);
extern  void comm_frame_upload(STR_COMM_FRAME *frame, STR_RINGBUF* bufhdl);
extern  uint8_t comm_frame_analysis(STR_COMM_FRAME *frame[], STR_RINGBUF* bufhdl);

extern  void upload_uartcomm_data(uint8_t cmd_id);

extern  void get_uartcomm_cmd(void);


#endif


